package edu.gdkm.dao;

import edu.gdkm.pojo.LoginInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ILoginInfoDao {
    @Select("select * from tab_login_info where id = #{id}")
    @Results(id="logininfowithuserinfo",value={
        @Result(property = "userInfo",
                column = "uid",
                one= @One(select = "edu.gdkm.dao.IUserInfoDao.queryUserInfoById"))
    })
    public LoginInfo queryLoginInfoById(Integer id);
    @Insert(value="insert into tab_login_info values(null,#{username},#{password},#{userInfo.uid})")
    public Integer insertLoginInfo(LoginInfo loginInfo);
    @Update("update tab_login_info set username = #{username},password=#{password} where id = #{id}")
    public Integer updateLoginInfo(LoginInfo loginInfo);
    @Delete("delete from tab_login_info where id=#{id}")
    public Integer deleteLoginInfoById(Integer id);
    @Select("select * from tab_login_info")
    @ResultMap("logininfowithuserinfo")
    public List<LoginInfo> queryLoginInfo();
    @Select("select * from tab_login_info where username=#{username} and password=#{password}" )
    public LoginInfo queryLoginInfoByUsernameAndPassword(@Param("username") String username,
                                                         @Param("password") String password);
}
